<?php

/*===============微信商城=================*/
/*----------------------------------------*/
/* $Author: 疯中追风                      */
/*----------------------------------------*/
/* $Time: 2017/11/6 9:12                  */
/*----------------------------------------*/
/*================上传图片================*/

namespace  Home\Model;
use Think\Model;

class CommentModel extends Model{

	//文件上传
	public function saveData($files){
		
		//接受并处理多个文件的上传
		$result = array();
		//配置路径
		$cfg = array(
			'rootPath' => WORKING_PATH.UPLOAD_ROOT_PATH."2017/",
		);
		for($i = 0; $i<count($files); $i++){
		
			$v = $i+1;
			//如果出现错误，就返回false
			if(!$files["photo".$v]["error"]){
				//处理上传
				$upload = new \Think\Upload($cfg); 
				$upload -> maxSize = 4000000; //设置上传大小
		    	$upload -> ext = array('jpg','gif','jpeg','png'); //设置上传类型
				//开始上传
				$result[$i] = $upload -> uploadOne($files["photo".$v]);
			}else{
				return false;
			}
		}
		return $result;
	}
}